<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>slot - 应用</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app">
    <btn :classa="classa">
        <template>{{text}}</template>
    </btn>
    <div>
        <button type="button" class="btn btn-default" @click="aaa('btn-default','默认')">默认</button>
        <button type="button" class="btn btn-success" @click="aaa('btn-success','安全')">安全</button>
        <button type="button" class="btn btn-warning" @click="aaa('btn-warning','警告')">警告</button>
    </div>
</div>
<template id="btn">
    <button :class="['btn',classa]"><slot>{{text}}</slot></button>
</template>
<script src="../vue.js"></script>
<script>
    var btn = {
        props:{
            classa: {
              type:String,
          },
          text: {
              type: String,
          }
        },
        template:'#btn',
    }
    new Vue({
        el:'#app',
        data(){
            return{
                classa:'',
                text:'按钮'
            }
        },
        components:{
            btn,
        },
        methods:{
            aaa:function (classa,text) {
                console.log(text);
                this.classa = classa;
                this.text = text;
            }
        }
    })
</script>
</body>
</html>